clear
set matsize 10000
use "${data}IndirectSurveyDataReplication.dta", clear

gen missing_one = total_ns > = 1
estimates clear
estpost sum coche_ns paredes_vivienda_ns television_ns tel_movil_ns jefe_secondaria_ns  
 
esttab using "${outputs}missing.tex", cell("mean(fmt(3) label(Mean)) sd(fmt(3) label(SD)) count(fmt(0) label(Obs ))") ///
style(tex) label nonumbers noobs replace ///
	postfoot( \hline \hline \end{tabular}} \begin{tablenotes}[para,flushleft] \footnotesize{Table shows proportions of ///
	``don't know'' responses for each variable in the indirect survey.} \end{tablenotes} ) 
 
estpost tab total_ns
esttab . using "${outputs}total_missing.tex", replace nonumber nomtitles nodepvars nonumbers ///
 label fragment collabels("" "" "" )  cells("b(fmt(0)) pct(fmt(2))") noobs ///
 prehead( {\begin{tabular}{lll} \hline \hline  Number missing & Frequency & Percent \\ ) ///
    postfoot( \hline \hline \end{tabular} } \begin{tablenotes}[para,flushleft] \footnotesize{Cells show frequency ///
	and percentages for each number of missing responses.} \end{tablenotes} )

 
 xi: reg missing_one assets_simple lider_edad lider_educ soc_cap_simple num_ejidatarios i.entidad, cluster(ejnclnmid)
 estimates store colols
 xtreg missing_one assets_simple, fe i(ejnclnmid) cluster(ejnclnmid)
estimates store colfe
 
 
esttab colols colfe  ///
	using "${outputs}missingpoverty.tex",  ///
	se nonotes  style(tex)  b(%12.3f) se(%12.3f)  noobs ///
	starlevels(* 0.10 ** 0.05 *** 0.01) label mlabels("" "" ) ///
	 keep(assets_simple lider_edad lider_educ soc_cap_simple num_ejidatarios_IHS ) nonumbers  replace  fragment  ///
	prehead( { \begin{tabular}{lcc} \hline \hline  & OLS & Ejido FE \\ ) ///
	postfoot(\hline \hline \end{tabular} } \begin{tablenotes}[para,flushleft] \tiny{Notes: Regressor is an indicator equal to ///
	one if there is at least one ``don't know'' response in the indirect survey.  The asset index is calculated from all the household ///
	data reported at the household level. Standard errors are clustered at the ejidal level and regressions are simple OLS ///
	with a constant. The OLS estimations include state fixed effects.} \end{tablenotes} )
